package com.baosight.risk.mapper.zbaa;

import com.baosight.risk.base.mapper.BaseMapper;
import com.baosight.risk.service.rire.entity.RireRiskTarget;
import com.baosight.risk.service.xtzy.entity.XtzyCompany;
import com.baosight.risk.service.zbaa.entity.ZbaaTargetValue;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public interface ZbaaTargetValueMapper extends BaseMapper<ZbaaTargetValue> {

    //获取历史数据
    List<ZbaaTargetValue> getHistory(@Param("targetId") String targetId, @Param("count") Integer count);

    //获取历史数据
    List<ZbaaTargetValue> getAllHistory(@Param("targetId") String targetId);

    //获取历史数据 时间范围
    List<ZbaaTargetValue> getValue(@Param("targetNo") String targetNo, @Param("sysSourceList") List<String> sysSourceList, @Param("compCodeList") List<String> compCodeList, @Param("startTime") String startTime, @Param("endTime") String endTime);

    //获取订阅指标数据的部门
    List<XtzyCompany> getXtzyCompanyByTargetNo(@Param("targetNo") String targetNo);

    String getLatestValue(@Param("targetNo") String targetNo, @Param("compCode") String compCode,
                          @Param("flag") String flag, @Param("mouth") List<String> mouth);

    ZbaaTargetValue getReferenceValue(@Param("targetNo") String targetNo, @Param("compCode") String compCode, @Param("period") List<String> period, @Param("periodType") String periodType);

    Integer updateReferenceValue(@Param("id") String id, @Param("targetValue") String targetValue);


    String getAverageValue(@Param("targetNo") String targetNo, @Param("compCode") String compCode,
                           @Param("year") String year, @Param("mouth") List<String> mouth);

    String getSumValue(@Param("targetNo") String targetNo, @Param("compCode") String compCode,
                       @Param("year") String year, @Param("mouth") List<String> mouth);

    /**
     * @description 批量插入指标数据
     * @author CuiShiHao
     * @date 2019/8/9
     */
    Integer insertValueList(@Param("list") List<ZbaaTargetValue> list);

    List<ZbaaTargetValue> getCompByTarget(@Param("targetNos") List<String> targetNos);

    List<ZbaaTargetValue> queryTargetValue(@Param("targetNo") String targetNo,
                                           @Param("compCode") String compCode,
                                           @Param("periodNo") String periodNo);


    List<ZbaaTargetValue> getLastZbaaTargetInfo(@Param("targetNo") String targetNo, @Param("sysSource") String sysSource, @Param("compCode") String compCode, @Param("periodNo") String periodNo, @Param("limitCount") String limitCount);

    /**
     * 查询近几天的东方钢铁指标值
     *
     * @param targetValue 指标值
     */
    List<ZbaaTargetValue> selectBsteelTargetValue(@Param("targetValue") ZbaaTargetValue targetValue);

    List<Map<String, String>> getUpdateActualValueTarget();

    /**
     * 删除指定条件的东方钢铁指标值
     *
     */
    Integer deleteValueByBsteel(@Param("targetValue") ZbaaTargetValue targetValue);

    ZbaaTargetValue checkMaxDate();

    ZbaaTargetValue checkMaxDateTask();

    List<ZbaaTargetValue> getAll();

    //获取汽车销量历史数据
    List<ZbaaTargetValue> getHistoryOfCar(@Param("targetId") String targetId, @Param("count") Integer count);

    /**
     * 查询Ext3 为空的先行指标数据 (未发送过的数据)
     * @param zbaaTargetValue
     * @return
     */
    List<ZbaaTargetValue> selectUnsentCount(@Param("target") ZbaaTargetValue zbaaTargetValue);
    
    List<ZbaaTargetValue> queryNewTargetByUserCode(@Param("userCode") String userCode);
}